package StudyCode.summary.regularexpressionsmatch;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CapturingTextInAGroupInARegularExpression {
	public static void main(String[] argv) throws Exception {
		CharSequence inputStr = "abbabcd";
		String patternStr = "(a(b*))+(c*)";

		Pattern pattern = Pattern.compile(patternStr);
		Matcher matcher = pattern.matcher(inputStr);
		boolean matchFound = matcher.find();

		if (matchFound) {
			for (int i = 0; i <= matcher.groupCount(); i++) {
				String groupStr = matcher.group(i);
				System.out.println("匹配结果:" + groupStr);
			}
		}
	}
}
